<template>
  <!-- <div :class="className" :style="{height:height,width:width}" /> -->
  <div class="com_container">
    <el-card class="box-card">
     
      <div slot="header" class="clearfix">
        <el-row type="flex" justify="center">
          <span>{{ title }}</span>
        </el-row>
        <el-button
          style="float: right; padding: 3px 0"
          type="text"
          v-if="cardLeft"
          >操作按钮</el-button
        >
      </div>
      <div style="text-align: center; margin-bottom: 20px;">
        <el-select
						v-model="fillterRole"
						collapse-tags
						filterable
						placeholder="选择角色筛选"
						clearable
						style="width: 200px; margin: 0 10px 0 0px"
            @change="getDataFn()"
					>
						<el-option v-for="item in RoleList" :key="item.id" :label="item.name" :value="item.id" />
					</el-select>
         <el-date-picker v-model="BeginTime" @change="getDataFn()" type="datetime" style="margin-right: 10px; width: 150px;" placeholder="开始时间"></el-date-picker>
					<el-date-picker v-model="EndTime" @change="getDataFn()" type="datetime" placeholder="结束时间" style="width: 150px;"></el-date-picker>
      </div>
      <el-table
        :data="list"
        border
        :row-class-name="columnColor"
      >
        <el-table-column label="业务员" align="center">
          <template slot-scope="{ row }">
            {{ row.employeeName }}
          </template>
        </el-table-column>
        <el-table-column label="总邀请酒吧" show-overflow-tooltip align="center">
          <template slot-scope="scope">
            {{ scope.row.totalEnterprises}}
          </template>
        </el-table-column>
        <el-table-column label="已认证酒吧" align="center">
          <template slot-scope="scope">
            {{ scope.row.certifiedEnterprises }}
          </template>
        </el-table-column>
        <el-table-column label="有扫码记录的酒吧" align="center">
          <template slot-scope="scope">
            {{ scope.row.codesScannedEnterprises }}
          </template>
        </el-table-column>
        <el-table-column label="总共扫码的次数" align="center">
          <template slot-scope="scope">
            {{ scope.row.codesScannedCount }}
          </template>
        </el-table-column>
        <el-table-column label="认证百分比" align="center">
          <template slot-scope="scope">
            {{ scope.row.certifiedPercentage||0 }}%
          </template>
        </el-table-column>
        <el-table-column label="扫码百分比" align="center">
          <template slot-scope="scope">
            {{ scope.row.scannedPercentage||0 }}%
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
// import { number } from 'echarts/lib/export'
import {GetSalesmanOperatingValues} from '@/api/system';
import { GetRolesPage } from '@/api/accessmanage';
export default {
  data() {
    return {
      list: [ ],
      BeginTime:'',
      EndTime:'',
      fillterRole:'',
      RoleList:[],
    }
  },
  props: {
    cardLeft: {
      type: Boolean,
      default: false,
    },
    height: {
      type: String,
      default: "600px",
    },
    title: {
      type: String,
      default: "卡片名称",
    },
  },
  created(){
    this.getRoleListFn();
    this.getDataFn();
  },
  methods: {
    	// 获取筛选的角色列表
		async getRoleListFn(){
			let res = await GetRolesPage({pageSize:999,pageIndex:1});
			if(res.code === 200){
				this.RoleList = res.data.list||[];
			}else{
				this.$message.error('获取分类列表失败，错误信息：'+res.erroMessage)
			}
		},
    async getDataFn(){
      let params = {};
      if(this.BeginTime !==''){
        params.BeginTime = this.BeginTime;
      }
      if(this.EndTime !==''){
        params.EndTime = this.EndTime;
      }
      if(this.fillterRole !==''){
        params.RoleId = this.fillterRole;
      }
      const res = await GetSalesmanOperatingValues(params)
      console.log(res);
      if(res.code === 200){
        this.list = res.data;
      }else{
        this.$message.error('获取拓展数据失败')
      }
    },
    getLocalTime: function (nS) {
      return new Date(parseInt(nS) * 1000)
        .toLocaleString()
        .replace(/:\d{1,2}$/, " ");
    },
    statusType: function (status) {
      const statusTex = {
        1: "草稿",
        2: "等待审批",
        3: "开始审批",
        4: "已拒绝",
        5: "已同意",
        6: "已完成",
      };
      return statusTex[status] || "无";
    },
    columnColor: function (row) {
      const statusTex = {
        1: "",
        2: "wait-row",
        3: "start-row",
        4: "failed-row",
        5: "ageen-row",
        6: "success-row",
      };
      if(row.rowIndex === this.list.length-1){
        return 'success-row'
      }else{
        return statusTex[row.row.status] || "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.com_container {
  width: 100%;
  height: 100%;
  padding: 0px;
}
.box-card {
  margin-bottom: 20px;
}
.box-card::v-deep .el-card__header{
  background: #ffdab9;
} 
.table-header-bg {
  background: #ff8247;
}
.el-table .wait-row {
  background: #ffffe0;
}
.el-table .start-row {
  background: #bfefff;
}
.el-table .failed-row {
  background: #ffaeb9;
}
.el-table .ageen-row {
  background: #b4eeb4;
}

</style>
<style >
.success-row {
  background-color: #ffdab9 !important;
}
</style>